package com.DJ;

import java.io.*;

public class fileUpload {
    @org.junit.Test
    public void fileupload(){
        String filepath = "D:\\develop\\code\\DJ\\DJ_admin\\src\\test\\java\\com\\DJ\\Main.java";
        try {

            //读取 输入流
            InputStreamReader input = new InputStreamReader(new FileInputStream(filepath));
            //写入 输出流
            OutputStreamWriter output = new OutputStreamWriter(new FileOutputStream("D:\\develop\\code\\DJ\\DJ_admin\\log\\Main2.java"));
            //缓冲 避免乱码
            BufferedReader br = new BufferedReader(input);
            BufferedWriter bw = new BufferedWriter(output);
            String str = null;
            while ((str = br.readLine()) != null) {
                bw.write(str);
                bw.newLine();
                bw.flush();//必须加上，否则得不到结果//必须加上，写完需要刷新，否则没结果
            }
            input.close();
            output.close();
            br.close();
            bw.close();

        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
